﻿@model SDSystem.Models.ServiceMaintain   
@using Ext.Net.MVC;
@using Ext.Net;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Header{
    <script type="text/javascript">
        var cbChange1 = function(e) {
            if (e.checked) {
                Ext.getCmp("extendField").enable();
            } else {
                Ext.getCmp("extendField").disable();
            }
        };
        var cbChange2 = function(e) {
            if (e.checked) {
                Ext.getCmp("limitField").enable();
            } else {
                Ext.getCmp("limitField").disable();
            }
        };
        var comboChange1 = function(e) {
            if (e.value == "Contract") {
                Ext.getCmp("tabContract").enable();
                Ext.getCmp("tabContract").show();
            } else {
                Ext.getCmp("tabContract").disable();
            }
            if (e.value == "Funding") {
                Ext.getCmp("tabFunding").enable();
                Ext.getCmp("tabFunding").show();
                Ext.getCmp("tabContact").clear();
            } else {
                Ext.getCmp("tabFunding").disable();
            }

        };
        var cbFunding1 = function(e) {
            if (e.checked) {
                Ext.getCmp("fundingContinuationAmount").enable();
                Ext.getCmp("fundingContinuationDetails").enable();
            } else {
                Ext.getCmp("fundingContinuationAmount").disable();
                Ext.getCmp("fundingContinuationDetails").disable();
            }
        };
        var cbFunding2 = function(e) {
            if (e.checked) {
                Ext.getCmp("fundraisingCompleteDate").enable();
            } else {
                Ext.getCmp("fundraisingCompleteDate").disable();
            }
        };
    </script>
    
}


@(Html.X().FormPanel()
      .ID("FormPanel1")
      .MarginSpec("0 0 0 0")
      .TopBar(Html.X().Toolbar().Items(items =>
                                           {
                                               items.Add(new ToolbarTextItem {Text = "<h3 style=\"color:green\">Service Details</h3>"});

                                               items.Add(new ToolbarFill());
                                           })
                  .Items(
                      Html.X().Button().ID("btnSave").Text("<b>Save</b>").Margins("0 20 0 0").Icon(Icon.ScriptSave)
                      .DirectEvents(de =>
                                    {
                                        de.Click.Url = Url.Action("Save");
                                        de.Click.EventMask.ShowMask = true;
                                        de.Click.FormID = "FormPanel1";
                                        //de.Click.Confirmation.ConfirmRequest = true;
                                        //de.Click.Confirmation.Title = "Title";
                                        //de.Click.Confirmation.Message = "Sample Confirmation Message...";


                                    })
                                    .Listeners(ls => ls.Click.Handler = "window.parent.location.reload();parentAutoLoadControl.close();"),
                      Html.X().Button().Text("<b>Back</b>").Icon(Icon.PageBack).Margins("0 20 0 0").Listeners(ls => ls.Click.Handler = "parentAutoLoadControl.close();")
                                                            
                  )

      )
      //.Listeners(ls => ls.ValidityChange.Handler="App.")
      .Items(
          Html.X().TabPanel()
              .ID("ServiceTabPanel")
              .MarginSpec("0 0 0 0")
              .Items(
                  Html.X().FormPanel()
                      .BodyPadding(10)
                      .ID("Detail1")
                      .Title("Detail1")
                      .Layout(LayoutType.Form)
                      .Items(
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().TextFieldFor(m => m.ServiceName).Flex(1).Margins("0 10 10 5").FieldLabel("Service Name <font color=\"red\">*</font>").LabelWidth(200).MsgTarget(MessageTarget.Side	),
                                  Html.X().Checkbox().ID("checkServiceActive").Flex(1).Margins("0 10 10 5").FieldLabel("Service Active").LabelWidth(200)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().TextAreaFor(m => m.ServiceShortDes).Rows(3).Flex(1).Margins("0 10 10 5").FieldLabel("Service Short Description <font color=\"red\">*</font>").LabelWidth(200).MsgTarget(MessageTarget.Side	),
                                  Html.X().TextAreaFor(m => m.ServiceFullDes).Rows(3).Flex(1).Margins("0 10 10 5").FieldLabel("Service Full Description").LabelWidth(200)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().ComboBoxFor(m => m.SubType).ID("subType").Flex(1).Margins("0 10 10 5").FieldLabel("Sub Type").LabelWidth(200)
                                      .Items(new ListItem("Funding", "Funding"), new ListItem("Contract", "Contract")).Listeners(
                                          ls => ls.Change.Fn="comboChange1"),
                                  Html.X().TextFieldFor(m => m.DeptCode).Flex(1).Margins("0 10 10 5").FieldLabel("Dept Code <font color=\"red\">*</font>").LabelWidth(200).MsgTarget(MessageTarget.Side)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.HBox).Items(
                                      Html.X().TextField().ID("ContactLookup").Margins("0 10 10 0").FieldLabel("Lead Contact <font color=\"red\">*</font>").LabelWidth(200).AllowBlank(false).MsgTarget(MessageTarget.Side),
                                      Html.X().HiddenFor(m => m.ContactId).ID("hIdLookup"),
                                      Html.X().LinkButton().Text("Lookup").Margins("0 155 10 5").Listeners(
                                          li => li.Click.Handler = "showWindow('Lookup','/Contact/List/?text=ContactLookup&id=hIdLookup',true,0.85,0.85);")
                                      ),
                                  Html.X().ComboBoxFor(m => m.ServiceType).Flex(1).Margins("0 10 10 5").FieldLabel("Service Type <font color=\"red\">*</font>").LabelWidth(200).Items(
                                      ViewBag.ServiceType
                                      ).MsgTarget(MessageTarget.Side)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().TextAreaFor(m => m.ClientDescription).Rows(3).Flex(1).Margins("0 10 10 5").FieldLabel("Client Description").LabelWidth(200),
                                  Html.X().TextAreaFor(m => m.ServiceDesDelivery).Rows(3).Flex(1).Margins("0 10 10 5").FieldLabel("Service Description-Delivery").LabelWidth(200)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().ComboBoxFor(m => m.ServiceAttendance).Flex(1).Margins("0 10 10 5").FieldLabel("Service Attendance").LabelWidth(200),
                                  Html.X().TextFieldFor(m => m.ServiceContractCode).Flex(1).Margins("0 10 10 5").FieldLabel("Service Contract Code").LabelWidth(200)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().DateFieldFor(m => m.ServiceStartExpected).ID("startExpected").FieldLabel("Service Start Expected").LabelWidth(200).EmptyText("<dd/MM/yy>")
                                      ),
                                  Html.X().TextFieldFor(m => m.ServiceContractValue).Flex(1).Margins("0 10 10 5").FieldLabel("Service Contract Value").LabelWidth(200)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().DateFieldFor(m => m.ServiceStartDate).ID("startDate").FieldLabel("Service Start Date").LabelWidth(200).EmptyText("<dd/MM/yyy>")
                                      ),
                                  Html.X().Checkbox().ID("checkStagePayment").Flex(1).Margins("0 10 10 5").FieldLabel("Contract Staged Payment").LabelWidth(200)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().DateFieldFor(m => m.ServiceEndDate).ID("endDate").FieldLabel("Service End Date").LabelWidth(200).EmptyText("<dd/MM/yyy>")
                                      ),
                                  Html.X().ComboBoxFor(m => m.ReferralProcess).Flex(1).Margins("0 10 10 5").FieldLabel("Referral Process/Method").LabelWidth(200)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().Checkbox().ID("checkServiceExtendable").FieldLabel("Service Extendable").LabelWidth(200).Listeners(
                                          ls => ls.Change.Fn="cbChange1"),
                                      Html.X().FieldContainer().ID("extendField").Margins("0 10 10 5").Layout(LayoutType.HBox).Items
                                          (
                                              Html.X().NumberField().ID("yearEx").MinValue(0).Value(0).Step(1).Margins("0 0 10 200").Width(60),
                                              Html.X().Label().Text("Years").Margins("0 10 10 5"),
                                              Html.X().NumberField().ID("monthEx").MinValue(0).MaxValue(11).Value(0).Step(1).Margins("0 0 10 5").Width(60),
                                              Html.X().Label().Text("Months").Margins("0 10 10 5")
                                          ).Disabled(true)
                                      ),
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().Checkbox().ID("checkServiceTimeLimited").FieldLabel("Service Time Limited").LabelWidth(200).Listeners(
                                          ls => ls.Change.Fn="cbChange2"),
                                      Html.X().FieldContainer().ID("limitField").Margins("0 10 10 5").Layout(LayoutType.HBox).Items
                                          (
                                              Html.X().NumberField().ID("yearLi").MinValue(0).Value(0).Step(1).Margins("0 0 10 200").Width(60),
                                              Html.X().Label().Text("Years").Margins("0 10 10 5"),
                                              Html.X().NumberField().ID("monthLi").MinValue(0).MaxValue(11).Value(0).Step(1).Margins("0 0 10 5").Width(60),
                                              Html.X().Label().Text("Months").Margins("0 10 10 5")
                                          ).Disabled(true)
                                      ))
                      ),

                  Html.X().FormPanel()
                      .Title("Detail2")
                      .BodyPadding(10)
                      .Layout(LayoutType.Form)
                      .Items(
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().MultiCombo().ID("ServiceBenefitsCriterion").FieldLabel("Service Benefits Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                          .Items(ViewBag.ServiceBenefitsCriterion),
                                  Html.X().MultiCombo().ID("ServiceDisability").FieldLabel("Service Disability Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.ServiceDisability)),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().MultiCombo().ID("ServiceBarriers").FieldLabel("Service Barriers Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.ServiceBarriers),
                                  Html.X().MultiCombo().ID("ServicePersonal").FieldLabel("Service Personal Circumstances Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.ServicePersonal)),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().MultiCombo().ID("ServiceEthnicity").FieldLabel("Service Ethnicity Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.ServiceEthnicity),
                                  Html.X().MultiCombo().ID("OtherServiceParticipation").FieldLabel("Other Service Participation Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.OtherServiceParticipation))
                            ),
                  Html.X().FormPanel()
                      .Title("Detail3")
                      .BodyPadding(10)
                      .Layout(LayoutType.Form)
                      .Items(
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().MultiCombo().ID("ClientSupportProcess").FieldLabel("Client Support Process").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.ClientSupportProcess),
                                  Html.X().MultiCombo().ID("ClientOutcome").FieldLabel("Client Outcome").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.ClientOutcome)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().MultiCombo().ID("Intervention").FieldLabel("Intervention").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.Intervention),
                                  Html.X().MultiCombo().ID("TargetClient").FieldLabel("Target Client").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.TargetClient)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().MultiCombo().ID("ClientJourney").FieldLabel("Client Journey").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.ClientJourney),
                                  Html.X().MultiCombo().ID("Accreditations").FieldLabel("Accreditations").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.Accreditations)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().MultiCombo().ID("OtherServices").FieldLabel("Other Services").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.OtherServices),
                                  Html.X().MultiCombo().ID("ReferralSources").FieldLabel("Referral Sources").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.ReferralSources)
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().MultiCombo().ID("SupportCentres").FieldLabel("Support Centres").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                      .Items(ViewBag.SupportCentres),
                                  Html.X().ComboBoxFor(m => m.Programme).FieldLabel("Programme").Items(ViewBag.Programme).LabelWidth(200).Margins("0 10 10 5").Flex(1)
                              )
                      ),
                  Html.X().FormPanel()
                      .Disabled(true)
                      .ID("tabContract")
                      .Title("Contract")
                      .Layout(LayoutType.Form)
                      .BodyPadding(10)
                      .Hidden(false)
                      .Items(
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer()
                                      .Layout(LayoutType.VBox)
                                      .Flex(1)
                                      .Items(
                                          Html.X().MultiComboFor(m => m.ContractOutcome).FieldLabel("Contract Outcome").LabelWidth(200).Margins("0 10 10 5")
                                              .Items(
                                                  Html.X().ListItem().Text("Referrals Taken"),
                                                  Html.X().ListItem().Text("Job Starts"),
                                                  Html.X().ListItem().Text("Retentions"),
                                                  Html.X().ListItem().Text("Accredited Training"),
                                                  Html.X().ListItem().Text("Motivation Improved")

                                              ),
                                          Html.X().ComboBoxFor(m => m.Participation).FieldLabel("Participation").LabelWidth(200).Margins("0 10 10 5")
                                      ),
                                  Html.X().FieldContainer()
                                      .Layout(LayoutType.VBox)
                                      .Flex(1)
                                      .Items(
                                          Html.X().MultiComboFor(m => m.ContractObligation).FieldLabel("Contract Obligation").LabelWidth(200).Margins("0 10 10 5")
                                              .Items(
                                                  Html.X().ListItem().Text("Phone Weekly"),
                                                  Html.X().ListItem().Text("Email Weekly")

                                              )
                                      )
                              )
                      ),

                  Html.X().FormPanel()
                      .Disabled(true)
                      .ID("tabFunding")
                      .Title("Funding")
                      .BodyPadding(10)
                      .Layout(LayoutType.Form)
                      .Hidden(false)
                      .Items(
                          //General
                      Html.X().FieldSet().Title("General").Collapsible(false).Layout(LayoutType.Form).Items(
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().ComboBoxFor(m => m.FundingSource).Flex(1).Margins("0 10 10 5").FieldLabel("Funding Source").LabelWidth(200),
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().TextFieldFor(m => m.FundingNeeds).FieldLabel("Funding Needs").LabelWidth(200)
                                      )  
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.HBox).Items(
                                      Html.X().TextField().ID("ContactLookup1").Margins("0 10 10 0").FieldLabel("Funding Contact Details <font color=\"red\">*</font>").LabelWidth(200).ReadOnly(true).AllowBlank(false).MsgTarget(MessageTarget.Side),
                                      Html.X().HiddenFor(m => m.FundingContactDetail).ID("hIdLookup1"),
                                      Html.X().LinkButton().Text("Lookup").Margins("0 155 10 5").Listeners(
                                          li => li.Click.Handler = "showWindow('Lookup','/Contact/List/?text=ContactLookup1&id=hIdLookup1',true,0.85,0.85);")
                                      ),
                                  Html.X().CheckboxFor(m =>m.FundingContinuationNeeded).Flex(1).Margins("0 10 10 5").FieldLabel("Funding Continuation Needed").LabelWidth(200)
                                      .Listeners(ls => ls.Change.Fn="cbFunding1")
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().TextFieldFor(m=>m.FundingAmount).ID("fundingAmount").FieldLabel("Funding Amount <font color=\"red\">*</font>").LabelWidth(200).AllowBlank(false).MsgTarget(MessageTarget.Side)
                                      ),
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().TextFieldFor(m =>m.FundingContinuationAmount).ID("fundingContinuationAmount").Margins("0 10 10 5").FieldLabel("Funding Continuation Amount").LabelWidth(200).Disabled(true)
                                      )),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().DateFieldFor(m => m.FundingStart).FieldLabel("Funding Start").LabelWidth(200).EmptyText("<dd/MM/yy>"),
                                      Html.X().DateFieldFor(m => m.FundingEnd).FieldLabel("Funding End").LabelWidth(200).EmptyText("<dd/MM/yy>")
                                      ),
                                  Html.X().TextAreaFor(m => m.FundingContinuationDetails).ID("fundingContinuationDetails").FieldLabel("Funding Continuation Details").Rows(3).LabelWidth(200).Margins("0 10 10 5").Flex(1).Disabled(true)
                              )
                          ),
                      //Fundraising For Service Project
                      Html.X().FieldSet().Title("Fundraising For Service Project").Collapsible(false).Layout(LayoutType.Form).Items(
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().TextAreaFor(m => m.FundraisingForText).FieldLabel("Fundraising For Text").Rows(3).LabelWidth(200).Margins("0 10 10 5").Flex(1),
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().TextFieldFor(m => m.FundraisingNeeds).FieldLabel("Fundraising Need").LabelWidth(200),
                                      Html.X().DateFieldFor(m => m.FundraisingRequiredBy).FieldLabel("Fundraising Required By").LabelWidth(200).EmptyText("<dd/MM/yy>")
                                      )
                                
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().TextAreaFor(m => m.FundraisingWhy).FieldLabel("Fundraising Why").Rows(3).LabelWidth(200).Margins("0 10 10 5").Flex(1),
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().CheckboxFor(m => m.FundraisingComplete).FieldLabel("Fundraising Complete").LabelWidth(200)
                                          .Listeners(ls => ls.Change.Fn="cbFunding2"),
                                      Html.X().DateFieldFor(m =>m.FundraisingCompleteDate).ID("fundraisingCompleteDate").FieldLabel("Fundraising Complete Date").LabelWidth(200).EmptyText("<dd/MM/yy>").Disabled(true)
                                      )         
                              )),
                      
                      
                      //Fundraising Donor
                      Html.X().FieldSet().Title("Fundraising Donor").Collapsible(false).Layout(LayoutType.Form).Items(
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().CheckboxFor(m => m.FundraisingDonorAnonymous).FieldLabel("Fundraising Donor Anonymous").LabelWidth(200).Flex(1).Margins("0 10 10 5"),
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().DateFieldFor(m => m.FundraisingDonationDate).FieldLabel("Fundraising Donation Date").LabelWidth(200).EmptyText("<dd/MM/yy>")
                                      )
                              ),
                          Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                                  Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                      Html.X().TextFieldFor(m =>m.FundraisingDonorAmount).FieldLabel("Fundraising Donor Amount").LabelWidth(200)
                                      ),
                                  Html.X().CheckboxFor(m => m.FundraisingDonationIncremental).FieldLabel("Fundraising Donation Incremental").Flex(1).Margins("0 10 10 5").LabelWidth(200)       
                              ))
                      )
              )
      ))
                        